package cn.biplam.back.bean.ddl.sql2db;

import cn.biplam.back.sql.ddl.Table;
import cn.biplam.common.client.DbResource;
import cn.biplam.common.wrapper.ErrorMessage;

public class FKParser {
	
	/**数据源信息*/
	private DbResource mDbResource;
	/**Table对象*/
	private Table mTable;
	
	public FKParser(DbResource mDbResource,Table mTable){
		this.mDbResource = mDbResource;
		this.mTable = mTable;
	}
	
	/**
	 * 功能   得到外键创建语句
	 * @return
	 */
	public String getCreateFK()throws ErrorMessage {
		
		String sFk = "";
		
		try {
			Sql2DbFactory sf = new Sql2DbFactory(mDbResource,mTable);
			sFk = sf.getFk().toString();
		} catch (Exception e) {
			ErrorMessage mErrorMessage = new ErrorMessage(e);
			throw mErrorMessage;
		}

		return sFk;
	}
	
	/**
	 * 功能   得到外键创建语句
	 * @return
	 */
	public String getDropFK()throws ErrorMessage {
		
		String sFk = "";
		
		try {
			Sql2DbFactory sf = new Sql2DbFactory(mDbResource,mTable);
			sFk = sf.getFkDrop().toString();
		} catch (Exception e) {
			ErrorMessage mErrorMessage = new ErrorMessage(e);
			throw mErrorMessage;
		}

		return sFk;
	}
}
